Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Clue Slideshow Library #283

Merged
merged 20 commits into from
Apr 1, 2020
Merged

Clue Slideshow Library #283

merged 20 commits into from
Apr 1, 2020

Conversation

andreamah
Copy link
Contributor

Description:

Implementing backend library for Adafruit Slideshow (front end is already taken care of, since the backend sends frame-by-frame).

ORIGINAL CODE BY ADAFRUIT: https://github.com/adafruit/Adafruit_CircuitPython_Slideshow/blob/master/adafruit_slideshow.py

  • For the most part, I re-did the library. I did borrow some docstrings and function names.

DOCS: https://circuitpython.readthedocs.io/projects/slideshow/en/latest/api.html

File breakdown:

adafruit_slideshow.py: all of the libraries needed to run a slideshow
--> The SlideShow class is the main class containing slideshow model. There are two ways of proceeding: advance() and update(). Advance() will definitely change the active slideshow photo, whereas update() will check the last time you advanced and will only advance if SlideShow.dwell seconds has passed. If auto_advance is False, update() will never work.
--> self.BASE_DWELL and self.BASE_DWELL_DARK exist as a bit of a buffer to add when the photos are fully shown and when the screen is "dark" (applicable during fade effect) respectively. Using no delay on top of the self.dwell value seemed to have made the animation too fast

test_adafruit_slideshow.py: tests for slideshow
--> only iterates forwards and backwards on the photos using advance()

Extra features:

Since this library supports relative file locations, I needed to get the address to the users's file. This was already done in the CPX code, so I modified it so that this was stored in common instead. Thus, both CPX and CLUE could access this value.

  • This explains the changes to utils.py, express.py, and process_user_code.py

Type of change

  • New feature (non-breaking change which adds functionality)

Limitations:

Please describe limitations of this PR

Testing:

Below are some tests that I ran. The "img" folder contained ~6 images that fell into one of these categories for height and width:

  • 240 by 240 exactly
  • more than 240 in height and width
  • less than 240 in height and width
  • more that 240 in width but less than 240 in height

I also tested with invalid .bmp images and .png images to make sure that they were properly skipped.

from adafruit_slideshow import SlideShow, PlayBackDirection, PlayBackOrder
import board

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY,
    dwell=1,
    folder="img",
    loop=True,
    fade_effect=True,
    auto_advance=True,
    order=PlayBackOrder.RANDOM,
    direction=PlayBackDirection.BACKWARD,
)
for i in range(8):
    slideshow.advance()
from adafruit_slideshow import SlideShow, PlayBackDirection, PlayBackOrder
import board

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY,
    dwell=3,
    folder="img",
    loop=True,
    fade_effect=False,
    auto_advance=True,
    order=PlayBackOrder.ALPHABETICAL,
    direction=PlayBackDirection.FORWARD,
)
while slideshow.update():
    pass
from adafruit_slideshow import SlideShow, PlayBackDirection, PlayBackOrder
import board

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY,
    dwell=1,
    folder="img",
    loop=True,
    fade_effect=False,
    auto_advance=False,
    order=PlayBackOrder.ALPHABETICAL,
    direction=PlayBackDirection.FORWARD,
)

for i in range(2):
    slideshow.advance()
while slideshow.update():
    pass
from adafruit_slideshow import SlideShow, PlayBackDirection, PlayBackOrder
import board

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY,
    dwell=1,
    folder="img",
    loop=True,
    fade_effect=False,
    auto_advance=True,
    order=PlayBackOrder.ALPHABETICAL,
    direction=PlayBackDirection.FORWARD,
)

for i in range(2):
    slideshow.advance()
while slideshow.update():
    pass

Checklist:

  • My code follows the style guidelines of this project
  • My code has been formatted with npm run format and passes the checks in npm run check
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@isadorasophia isadorasophia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR description!! 💛 LGTM

src/clue/adafruit_slideshow.py Show resolved Hide resolved
src/process_user_code.py Show resolved Hide resolved
src/clue/adafruit_slideshow.py Outdated Show resolved Hide resolved
Copy link
Contributor

@vandyliu vandyliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff

@andreamah andreamah merged commit 717fc7c into dev Apr 1, 2020
@andreamah andreamah deleted the users/t-anmah/clue-slideshow branch April 1, 2020 22:31
@nasadigital nasadigital mentioned this pull request Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants